package app.fugema.shop.main.login.view;

import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.base.common.utils.DensityUtil;
import com.base.common.utils.OnClickCheckedUtil;
import com.base.common.utils.UIUtils;
import com.base.common.view.base.BaseDialogFragment;
import com.base.common.viewmodel.BaseViewModel;
import app.fugema.shop.R;
import app.fugema.shop.databinding.UserAgreementDialogFragment2Binding;

public class UserAgreementDialogFragment2 extends BaseDialogFragment<UserAgreementDialogFragment2Binding, BaseViewModel> {

    public static UserAgreementDialogFragment2 newInstance() {
        Bundle args = new Bundle();
        UserAgreementDialogFragment2 fragment = new UserAgreementDialogFragment2();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    protected UserAgreementDialogFragment2Binding initDataBinding(LayoutInflater inflater, ViewGroup container) {
        return DataBindingUtil.inflate(inflater, R.layout.user_agreement_dialog_fragment2, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        binding.tvTitle.setText("您需要同意本隐私政策才能继续使用" + UIUtils.getString(R.string.app_name));

        binding.btnCancel.setOnClickListener(new OnClickCheckedUtil() {
            @Override
            public void onClicked(View view) {
                dismiss();
                if (getActivity() != null) getActivity().finish();
            }
        });

        binding.btnSubmit.setOnClickListener(new OnClickCheckedUtil() {
            @Override
            public void onClicked(View view) {
                UserAgreementDialogFragment3 fragment3 = UserAgreementDialogFragment3.newInstance();
                fragment3.setCancelable(false);
                fragment3.showAnimation(false);
                if (getActivity() != null)
                    getActivity().getSupportFragmentManager().beginTransaction().add(fragment3, UserAgreementDialogFragment2.this.getClass().getSimpleName()).commit();
                dismiss();
            }
        });
    }

    @Override
    public void initData() {
        super.initData();


    }

    @Override
    protected boolean isCancel() {
        return false;
    }

    @Override
    public int getGravity() {
        return Gravity.CENTER;
    }

    @Override
    protected int getWidth() {
        return DensityUtil.getDimens(R.dimen.dp_295);
    }

}
